class Solution {
public:
    ListNode* FindKthToTail(ListNode* pHead, int k) {
        // write code here
        ListNode* cur = pHead;
        ListNode* pre = pHead;
        int count = 0;
        while (cur)
        {
            cur = cur->next;
            count++;
        }
        if (count < k)
            return nullptr;
        cur = pHead;
        while (k-- && cur)
            cur = cur->next;
        while (cur)
        {
            pre = pre->next;
            cur = cur->next;
        }
        return pre;
    }
};